//
//  FullScreenViewController.swift
//  Merchant
//
//  Created by 薛永伟 on 2019/5/13.
//  Copyright © 2019 Yuri. All rights reserved.
//

import UIKit

class FullScreenViewController: UIViewController {

    //MARK:属性
    typealias ViewRemovedHandle = () -> ()
    
    /// 完成回调
    var dismissedHandle : ViewRemovedHandle?
    
    /// 点击空白区域隐藏view
    var touchEmptyToHidden = true
    
    //MARK:控件
    
    
    fileprivate lazy var tapEmpty: UITapGestureRecognizer = {
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapEmptyView(tap:)))
        return tap
    }()
    
    //MARK: -
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        if isFirstAppear {
            self.animateShowContentView()
        }
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        view.alpha = 0
        
        view.addGestureRecognizer(tapEmpty)
        
    }
    

}

//MARK: - --------------类--------------

//MARK: - --------------响应事件--------------
extension FullScreenViewController {
    
     @objc fileprivate func tapEmptyView(tap:UITapGestureRecognizer){
        if touchEmptyToHidden {
            self.dismiss(animated: false, completion: dismissedHandle)
        }
    }
}
//MARK: - --------------数据请求--------------

//MARK: - --------------辅助方法--------------
extension FullScreenViewController {
    
    fileprivate func animateShowContentView(){
        
        UIView.animate(withDuration: 0.2, animations: {
            self.view.alpha = 1
        }) { (finished) in
            
        }
    }
    
}
//MARK: - --------------驱动UI--------------
